

#import "ModalViewController.h"
#import "Constants.h"

@interface ModalViewController ()
- (id)infoValueForKey:(NSString *)key;
@end

@implementation ModalViewController

@synthesize appName, copyright;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
	if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
        return nil;
    
    self.title = NSLocalizedString(@"ModalTitle", @"");
	
	return self;
}

- (void)dealloc
{
    [appName release];
    [copyright release];
	[super dealloc];
}

- (void)viewDidLoad
{
	self.view.backgroundColor = [UIColor whiteColor];
	
	self.appName.text = [self infoValueForKey:@"CFBundleName"];
	self.copyright.text = [self infoValueForKey:@"NSHumanReadableCopyright"];
}

- (void)viewDidUnload
{
	self.appName = nil;
	self.copyright = nil;
}

- (id)infoValueForKey:(NSString *)key
{
    // fetch objects from our bundle based on keys in our Info.plist
	return [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:key] ? : [[[NSBundle mainBundle] infoDictionary] objectForKey:key];
}

- (IBAction)dismissAction:(id)sender
{
	[self.parentViewController dismissModalViewControllerAnimated:YES];
}

@end
